﻿using UnityEngine;
using System.Collections;

public class Shoot : MonoBehaviour {

	public float velocity;
	public float point;
	public GameObject player;

	private bool directionLeft;

	// Use this for initialization
	void Start ()
	{
		player = GameObject.FindGameObjectWithTag("Player");

		if (player.transform.localScale.x <= 0)
			
			velocity = -5; 
		
		else if (player.transform.localScale.x > 0)
			velocity = 5; 
	}
	
	// Update is called once per frame
	void Update () 
	{
	
		transform.Translate(velocity *Time.deltaTime,0,0);

	}

	void OnTriggerEnter2D(Collider2D other)
	{
		if(other.gameObject.tag == "25");
		{
			transform.position = new Vector3 (0.14f,1.4f,0);
			lifes -= 1;
		}
		
		
		
		if(other.gameObject.tag == "10");
		{
			transform.position = new Vector3 (0.14f,1.4f,0);
			lifes -= 1;
		}
		
		//Debug.Log("to batendo em " + other.gameObject.tag);
		if(other.gameObject.tag == "20");
		{
			transform.position = new Vector3 (0.14f,1.4f,0);
			lifes -= 1;
		}
		
	
		if(other.gameObject.tag == "15");
		{
			transform.position = new Vector3 (0.14f,1.4f,0);
			lifes -= 1;
		}
		if(other.gameObject.tag == "10")
		{
			point +=10;
			
		}
		if(other.gameObject.tag == "15")
		{
			point +=15;
		}
		if(other.gameObject.tag == "20")
		{
			point +=20;
		}
		if(other.gameObject.tag == "25")
		{
			point +=25;
		}
	}
}
	